package com.yzlwb.web.controller.skt;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yzlwb.skt.domain.SktTaskHistory;
import com.yzlwb.skt.service.ISktTaskHistoryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yzlwb.common.annotation.Log;
import com.yzlwb.common.core.controller.BaseController;
import com.yzlwb.common.core.domain.AjaxResult;
import com.yzlwb.common.enums.BusinessType;

import com.yzlwb.common.utils.poi.ExcelUtil;
import com.yzlwb.common.core.page.TableDataInfo;

/**
 * 任务执行记录Controller
 * 
 * @author wfy
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/yzlwb/history")
public class SktTaskHistoryController extends BaseController
{
    @Autowired
    private ISktTaskHistoryService sktTaskHistoryService;

    /**
     * 查询任务执行记录列表
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(SktTaskHistory sktTaskHistory)
    {
        startPage();
        List<SktTaskHistory> list = sktTaskHistoryService.selectSktTaskHistoryList(sktTaskHistory);
        return getDataTable(list);
    }

    /**
     * 导出任务执行记录列表
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:export')")
    @Log(title = "任务执行记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SktTaskHistory sktTaskHistory)
    {
        List<SktTaskHistory> list = sktTaskHistoryService.selectSktTaskHistoryList(sktTaskHistory);
        ExcelUtil<SktTaskHistory> util = new ExcelUtil<SktTaskHistory>(SktTaskHistory.class);
        util.exportExcel(response, list, "任务执行记录数据");
    }

    /**
     * 获取任务执行记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sktTaskHistoryService.selectSktTaskHistoryById(id));
    }

    /**
     * 新增任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:add')")
    @Log(title = "任务执行记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SktTaskHistory sktTaskHistory)
    {
        return toAjax(sktTaskHistoryService.insertSktTaskHistory(sktTaskHistory));
    }

    /**
     * 修改任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:edit')")
    @Log(title = "任务执行记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SktTaskHistory sktTaskHistory)
    {
        return toAjax(sktTaskHistoryService.updateSktTaskHistory(sktTaskHistory));
    }

    /**
     * 删除任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('yzlwb:history:remove')")
    @Log(title = "任务执行记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sktTaskHistoryService.deleteSktTaskHistoryByIds(ids));
    }
}
